<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>类式组件</title>
    <style>
        #header{
            height: 100px;
            background: #aef;
        }
        #section{
            height: 400px;
            background: rgb(224, 223, 153);
        }

        #footer{
            height: 100px;
            background: rgb(235, 133, 222);
        }
    </style>
</head>
<body>
    <div id="root"></div>

    <script src="../js/react.development.js"></script>
    <script src="../js/react-dom.development.js"></script>
    <script src="../js/babel.min.js"></script>

    <script type="text/babel">
        class Header extends React.Component{
            //声明 render 方法
            render(){
                //返回虚拟 DOM
                return <div id="header"></div>;
            }
        }

        class Section extends React.Component{
            render(){
                return <div id="section"></div>;
            }
        }

        class Footer extends React.Component{
            render(){
                return <div id="footer"></div>;
            }
        }

        // Header 标签会寻找同名的『类』, 然后『实例化对象』,对象调用『render』方法,得到虚拟 DOM 对象
        class App extends React.Component{
            render(){
                return <div>
                            <Header></Header>
                            <Section />
                            <Footer />
                        </div>;
            }
        }

        ReactDOM.render(<App />, document.querySelector("#root"));
    </script>
</body>
</html>